package com.buddy.hadoop.hdfs;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.io.IOException;

public class CopyFile {
    public static void main(String[] args) throws IOException {
        Configuration conf = new Configuration();
        FileSystem hdfs = FileSystem.get(conf);
        Path src = new Path(args[0]);
        Path dst = new Path(args[1]);
        hdfs.copyFromLocalFile(src,dst);
        System.out.println("Upload to"+conf.get("fs.default.name"));
        FileStatus[] files = hdfs.listStatus(dst);
        for (FileStatus fileStatus : files){
            System.out.println(fileStatus.getPath());
        }
    }
}
